{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Make the polygon valid\n",
    "Fix self-Intersecting and other invalid polygons as in https://shapely.readthedocs.io/en/stable/manual.html"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Polygon from V. vinifera Jayakody2017 raw_dataset_1 Image_002.json is invalid: Self-intersection[4293.62 3598]\n",
      "Polygon from V. vinifera Jayakody2017 raw_dataset_1 Image_003.json is invalid: Self-intersection[3456.53 3598]\n",
      "Polygon from V. vinifera Jayakody2017 raw_dataset_1 Image_004.json is invalid: Ring Self-intersection[3362.21 3598]\n",
      "Polygon from V. vinifera Jayakody2017 raw_dataset_1 Image_008.json is invalid: Self-intersection[1911.37 3598]\n",
      "Polygon from V. vinifera Jayakody2017 raw_dataset_1 Image_010.json is invalid: Self-intersection[4798 2201.12504605937]\n",
      "Polygon from V. vinifera Jayakody2017 raw_dataset_1 Image_014.json is invalid: Ring Self-intersection[1 293.21]\n",
      "Polygon from V. vinifera Jayakody2017 raw_dataset_1 Image_017.json is invalid: Self-intersection[2798.04 3598]\n",
      "Polygon from V. vinifera Jayakody2017 raw_dataset_1 Image_022.json is invalid: Self-intersection[2829.6 3598]\n",
      "Polygon from V. vinifera Jayakody2017 raw_dataset_1 Image_022.json is invalid: Self-intersection[1543.35504 3598]\n",
      "Polygon from V. vinifera Jayakody2017 raw_dataset_1 Image_023.json is invalid: Self-intersection[2530.92956284153 3598]\n",
      "Polygon from V. vinifera Jayakody2017 raw_dataset_1 Image_033.json is invalid: Ring Self-intersection[3747.27 3598]\n",
      "Polygon from V. vinifera Jayakody2017 raw_dataset_1 Image_035.json is invalid: Self-intersection[3911.17 3598]\n",
      "Polygon from V. vinifera Jayakody2017 raw_dataset_1 Image_037.json is invalid: Self-intersection[1309.15958082002 1.00126224982684]\n",
      "Polygon from V. vinifera Jayakody2017 raw_dataset_1 Image_041.json is invalid: Self-intersection[1869.64 3598]\n"
     ]
    }
   ],
   "source": [
    "import os\n",
    "import json\n",
    "import glob\n",
    "from shapely.geometry import Polygon, MultiPolygon, GeometryCollection\n",
    "from shapely.validation import explain_validity, make_valid\n",
    "\n",
    "def shapely_valid_transform(input_dir: str = None, if_explain_invalid: bool = False):\n",
    "    \"\"\"Transform the polygons to be valid for further processing with libraries like Sahi and Shapely\"\"\"\n",
    "    json_paths = glob.glob(os.path.join(input_dir, f\"*{'.json'}\"))  # get all json file paths\n",
    "    for json_path in json_paths:\n",
    "        with open(json_path, 'r', encoding='utf-8') as file:\n",
    "            data = json.load(file)  # load the json data\n",
    "\n",
    "        for obj in data['objects']:\n",
    "            corrected_segmentation = []  # to collect valid segmentation points\n",
    "            min_x, max_x, min_y, max_y = float('inf'), float('-inf'), float('inf'), float('-inf')  # ensure updates will be replaced by real numbers\n",
    "\n",
    "            for point in obj['segmentation']:\n",
    "                x, y = point  # get the ISAT segmentation coordinates\n",
    "                if int(x) == 0:\n",
    "                    x += 1  # if the point locates on the left side, shift 1 pixel inward\n",
    "                elif int(x) == data['info']['width'] - 1:\n",
    "                    x -= 1  # if the point locates on the right side, shift 1 pixel inward\n",
    "                if int(y) == 0:\n",
    "                    y += 1  # if the point locates on the bottom, shift 1 pixel inward\n",
    "                elif int(y) == data['info']['height'] - 1:\n",
    "                    y -= 1  # if the points locates on the top, shift 1 pixel inward\n",
    "                corrected_segmentation.append([x, y])  # collect the corrected segmentation coordinates\n",
    "                min_x, max_x = min(min_x, x), max(max_x, x)  # get the min/max x to update bbox\n",
    "                min_y, max_y = min(min_y, y), max(max_y, y)  # same for y\n",
    "\n",
    "            polygon_shapely = Polygon(corrected_segmentation)  # noqa: convert the ISAT segmentation points to shapely format\n",
    "            if not polygon_shapely.is_valid:\n",
    "                if if_explain_invalid:\n",
    "                    invalid_reason = explain_validity(polygon_shapely)  # the reason for invalidity\n",
    "                    print(f\"Polygon from {os.path.basename(json_path)} is invalid: {invalid_reason}\")  # print the reason for invalidity\n",
    "                corrected_geometry = make_valid(polygon_shapely)\n",
    "                if isinstance(corrected_geometry, MultiPolygon):\n",
    "                    corrected_geometry = max(corrected_geometry.geoms, key=lambda polygon: polygon.area)  # selecting the largest polygon\n",
    "                elif isinstance(corrected_geometry, GeometryCollection):\n",
    "                    polygons = [geom for geom in corrected_geometry.geoms if isinstance(geom, Polygon)]  # filter out only polygonal components\n",
    "                    if polygons:\n",
    "                        corrected_geometry = max(polygons, key=lambda polygon: polygon.area)  # selecting the largest polygon\n",
    "                    else:\n",
    "                        continue  # if there are no polygons, use the original corrected_segmentation\n",
    "                corrected_segmentation = [[pt[0], pt[1]] for pt in corrected_geometry.exterior.coords[:-1]]  # update segmentation from the largest or corrected polygon\n",
    "\n",
    "            obj['segmentation'] = corrected_segmentation  # update segmentation coordinates\n",
    "            obj['bbox'] = [min_x, min_y, max_x, max_y]  # update the bbox\n",
    "\n",
    "        with open(json_path, 'w', encoding='utf-8') as file:\n",
    "            json.dump(data, file, indent=4)  # save the updated json data\n",
    "    return None\n",
    "\n",
    "\n",
    "input_dir = 'Datasets/Jayakody2017/Processed/V. vinifera - Copy'\n",
    "shapely_valid_transform(input_dir=input_dir, if_explain_invalid=True)"
   ]
  }
 ],
 "metadata": {
  "accelerator": "GPU",
  "colab": {
   "collapsed_sections": [
    "J2OtvBLRa2D3",
    "H0sxjxbvfWMb",
    "nyr4y8aiw4oK",
    "egEeiRr9uAj8",
    "833D0mbi-Mqz",
    "gEptYWuD8qjq",
    "gz5wcgGScwPi",
    "77_vyR9TC4p-",
    "sbFmyqnaiSaj",
    "gd9k1MHvooJ5"
   ],
   "machine_shape": "hm",
   "provenance": []
  },
  "gpuClass": "premium",
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.10.13"
  },
  "widgets": {
   "application/vnd.jupyter.widget-state+json": {
    "055d380628a048fe87905ea90e498f6e": {
     "model_module": "@jupyter-widgets/controls",
     "model_module_version": "1.5.0",
     "model_name": "HTMLModel",
     "state": {
      "_dom_classes": [],
      "_model_module": "@jupyter-widgets/controls",
      "_model_module_version": "1.5.0",
      "_model_name": "HTMLModel",
      "_view_count": null,
      "_view_module": "@jupyter-widgets/controls",
      "_view_module_version": "1.5.0",
      "_view_name": "HTMLView",
      "description": "",
      "description_tooltip": null,
      "layout": "IPY_MODEL_c720ecf0b60a44e19d7642da97226db5",
      "placeholder": "​",
      "style": "IPY_MODEL_80c476efea2e4e49b7f440de902e8bff",
      "value": " 137M/137M [00:06&lt;00:00, 24.4MB/s]"
     }
    },
    "057a070828cd45c5825178b0d0c2efc4": {
     "model_module": "@jupyter-widgets/controls",
     "model_module_version": "1.5.0",
     "model_name": "DescriptionStyleModel",
     "state": {
      "_model_module": "@jupyter-widgets/controls",
      "_model_module_version": "1.5.0",
      "_model_name": "DescriptionStyleModel",
      "_view_count": null,
      "_view_module": "@jupyter-widgets/base",
      "_view_module_version": "1.2.0",
      "_view_name": "StyleView",
      "description_width": ""
     }
    },
    "1849c69ad0dc49e5a27194c3e0fdb1b8": {
     "model_module": "@jupyter-widgets/controls",
     "model_module_version": "1.5.0",
     "model_name": "ProgressStyleModel",
     "state": {
      "_model_module": "@jupyter-widgets/controls",
      "_model_module_version": "1.5.0",
      "_model_name": "ProgressStyleModel",
      "_view_count": null,
      "_view_module": "@jupyter-widgets/base",
      "_view_module_version": "1.2.0",
      "_view_name": "StyleView",
      "bar_color": null,
      "description_width": ""
     }
    },
    "1cba8110810e4d619e5828c8fc2bbb8e": {
     "model_module": "@jupyter-widgets/controls",
     "model_module_version": "1.5.0",
     "model_name": "ProgressStyleModel",
     "state": {
      "_model_module": "@jupyter-widgets/controls",
      "_model_module_version": "1.5.0",
      "_model_name": "ProgressStyleModel",
      "_view_count": null,
      "_view_module": "@jupyter-widgets/base",
      "_view_module_version": "1.2.0",
      "_view_name": "StyleView",
      "bar_color": null,
      "description_width": ""
     }
    },
    "2337a836f29f49ea91987e4dbd67a0ff": {
     "model_module": "@jupyter-widgets/base",
     "model_module_version": "1.2.0",
     "model_name": "LayoutModel",
     "state": {
      "_model_module": "@jupyter-widgets/base",
      "_model_module_version": "1.2.0",
      "_model_name": "LayoutModel",
      "_view_count": null,
      "_view_module": "@jupyter-widgets/base",
      "_view_module_version": "1.2.0",
      "_view_name": "LayoutView",
      "align_content": null,
      "align_items": null,
      "align_self": null,
      "border": null,
      "bottom": null,
      "display": null,
      "flex": null,
      "flex_flow": null,
      "grid_area": null,
      "grid_auto_columns": null,
      "grid_auto_flow": null,
      "grid_auto_rows": null,
      "grid_column": null,
      "grid_gap": null,
      "grid_row": null,
      "grid_template_areas": null,
      "grid_template_columns": null,
      "grid_template_rows": null,
      "height": null,
      "justify_content": null,
      "justify_items": null,
      "left": null,
      "margin": null,
      "max_height": null,
      "max_width": null,
      "min_height": null,
      "min_width": null,
      "object_fit": null,
      "object_position": null,
      "order": null,
      "overflow": null,
      "overflow_x": null,
      "overflow_y": null,
      "padding": null,
      "right": null,
      "top": null,
      "visibility": null,
      "width": null
     }
    },
    "2584d7c435d540c7802af00f993567ae": {
     "model_module": "@jupyter-widgets/base",
     "model_module_version": "1.2.0",
     "model_name": "LayoutModel",
     "state": {
      "_model_module": "@jupyter-widgets/base",
      "_model_module_version": "1.2.0",
      "_model_name": "LayoutModel",
      "_view_count": null,
      "_view_module": "@jupyter-widgets/base",
      "_view_module_version": "1.2.0",
      "_view_name": "LayoutView",
      "align_content": null,
      "align_items": null,
      "align_self": null,
      "border": null,
      "bottom": null,
      "display": null,
      "flex": null,
      "flex_flow": null,
      "grid_area": null,
      "grid_auto_columns": null,
      "grid_auto_flow": null,
      "grid_auto_rows": null,
      "grid_column": null,
      "grid_gap": null,
      "grid_row": null,
      "grid_template_areas": null,
      "grid_template_columns": null,
      "grid_template_rows": null,
      "height": null,
      "justify_content": null,
      "justify_items": null,
      "left": null,
      "margin": null,
      "max_height": null,
      "max_width": null,
      "min_height": null,
      "min_width": null,
      "object_fit": null,
      "object_position": null,
      "order": null,
      "overflow": null,
      "overflow_x": null,
      "overflow_y": null,
      "padding": null,
      "right": null,
      "top": null,
      "visibility": null,
      "width": null
     }
    },
    "4420fb69a0be4aada0e2a2073304f470": {
     "model_module": "@jupyter-widgets/controls",
     "model_module_version": "1.5.0",
     "model_name": "HTMLModel",
     "state": {
      "_dom_classes": [],
      "_model_module": "@jupyter-widgets/controls",
      "_model_module_version": "1.5.0",
      "_model_name": "HTMLModel",
      "_view_count": null,
      "_view_module": "@jupyter-widgets/controls",
      "_view_module_version": "1.5.0",
      "_view_name": "HTMLView",
      "description": "",
      "description_tooltip": null,
      "layout": "IPY_MODEL_2584d7c435d540c7802af00f993567ae",
      "placeholder": "​",
      "style": "IPY_MODEL_057a070828cd45c5825178b0d0c2efc4",
      "value": "100%"
     }
    },
    "5002510e5a384d099ace0ab0243b93a4": {
     "model_module": "@jupyter-widgets/controls",
     "model_module_version": "1.5.0",
     "model_name": "HTMLModel",
     "state": {
      "_dom_classes": [],
      "_model_module": "@jupyter-widgets/controls",
      "_model_module_version": "1.5.0",
      "_model_name": "HTMLModel",
      "_view_count": null,
      "_view_module": "@jupyter-widgets/controls",
      "_view_module_version": "1.5.0",
      "_view_name": "HTMLView",
      "description": "",
      "description_tooltip": null,
      "layout": "IPY_MODEL_7d8ceea20d34420894f88011cd231d11",
      "placeholder": "​",
      "style": "IPY_MODEL_c0f8bcfa357048db8ed923f8ccbf9a21",
      "value": " 755k/755k [00:00&lt;00:00, 23.2MB/s]"
     }
    },
    "6a74007a00504d19992b51c71a81eaa1": {
     "model_module": "@jupyter-widgets/controls",
     "model_module_version": "1.5.0",
     "model_name": "HTMLModel",
     "state": {
      "_dom_classes": [],
      "_model_module": "@jupyter-widgets/controls",
      "_model_module_version": "1.5.0",
      "_model_name": "HTMLModel",
      "_view_count": null,
      "_view_module": "@jupyter-widgets/controls",
      "_view_module_version": "1.5.0",
      "_view_name": "HTMLView",
      "description": "",
      "description_tooltip": null,
      "layout": "IPY_MODEL_df5cf589b8e1417c983fac215ba3140a",
      "placeholder": "​",
      "style": "IPY_MODEL_fe0cbb8ecaf64742a9bfc5faf3b6c7d0",
      "value": "100%"
     }
    },
    "7c913117c35a415a999b5b8fe27193fb": {
     "model_module": "@jupyter-widgets/base",
     "model_module_version": "1.2.0",
     "model_name": "LayoutModel",
     "state": {
      "_model_module": "@jupyter-widgets/base",
      "_model_module_version": "1.2.0",
      "_model_name": "LayoutModel",
      "_view_count": null,
      "_view_module": "@jupyter-widgets/base",
      "_view_module_version": "1.2.0",
      "_view_name": "LayoutView",
      "align_content": null,
      "align_items": null,
      "align_self": null,
      "border": null,
      "bottom": null,
      "display": null,
      "flex": null,
      "flex_flow": null,
      "grid_area": null,
      "grid_auto_columns": null,
      "grid_auto_flow": null,
      "grid_auto_rows": null,
      "grid_column": null,
      "grid_gap": null,
      "grid_row": null,
      "grid_template_areas": null,
      "grid_template_columns": null,
      "grid_template_rows": null,
      "height": null,
      "justify_content": null,
      "justify_items": null,
      "left": null,
      "margin": null,
      "max_height": null,
      "max_width": null,
      "min_height": null,
      "min_width": null,
      "object_fit": null,
      "object_position": null,
      "order": null,
      "overflow": null,
      "overflow_x": null,
      "overflow_y": null,
      "padding": null,
      "right": null,
      "top": null,
      "visibility": null,
      "width": null
     }
    },
    "7d8ceea20d34420894f88011cd231d11": {
     "model_module": "@jupyter-widgets/base",
     "model_module_version": "1.2.0",
     "model_name": "LayoutModel",
     "state": {
      "_model_module": "@jupyter-widgets/base",
      "_model_module_version": "1.2.0",
      "_model_name": "LayoutModel",
      "_view_count": null,
      "_view_module": "@jupyter-widgets/base",
      "_view_module_version": "1.2.0",
      "_view_name": "LayoutView",
      "align_content": null,
      "align_items": null,
      "align_self": null,
      "border": null,
      "bottom": null,
      "display": null,
      "flex": null,
      "flex_flow": null,
      "grid_area": null,
      "grid_auto_columns": null,
      "grid_auto_flow": null,
      "grid_auto_rows": null,
      "grid_column": null,
      "grid_gap": null,
      "grid_row": null,
      "grid_template_areas": null,
      "grid_template_columns": null,
      "grid_template_rows": null,
      "height": null,
      "justify_content": null,
      "justify_items": null,
      "left": null,
      "margin": null,
      "max_height": null,
      "max_width": null,
      "min_height": null,
      "min_width": null,
      "object_fit": null,
      "object_position": null,
      "order": null,
      "overflow": null,
      "overflow_x": null,
      "overflow_y": null,
      "padding": null,
      "right": null,
      "top": null,
      "visibility": null,
      "width": null
     }
    },
    "80c476efea2e4e49b7f440de902e8bff": {
     "model_module": "@jupyter-widgets/controls",
     "model_module_version": "1.5.0",
     "model_name": "DescriptionStyleModel",
     "state": {
      "_model_module": "@jupyter-widgets/controls",
      "_model_module_version": "1.5.0",
      "_model_name": "DescriptionStyleModel",
      "_view_count": null,
      "_view_module": "@jupyter-widgets/base",
      "_view_module_version": "1.2.0",
      "_view_name": "StyleView",
      "description_width": ""
     }
    },
    "a1d5058472754e4099c024f9671236a3": {
     "model_module": "@jupyter-widgets/base",
     "model_module_version": "1.2.0",
     "model_name": "LayoutModel",
     "state": {
      "_model_module": "@jupyter-widgets/base",
      "_model_module_version": "1.2.0",
      "_model_name": "LayoutModel",
      "_view_count": null,
      "_view_module": "@jupyter-widgets/base",
      "_view_module_version": "1.2.0",
      "_view_name": "LayoutView",
      "align_content": null,
      "align_items": null,
      "align_self": null,
      "border": null,
      "bottom": null,
      "display": null,
      "flex": null,
      "flex_flow": null,
      "grid_area": null,
      "grid_auto_columns": null,
      "grid_auto_flow": null,
      "grid_auto_rows": null,
      "grid_column": null,
      "grid_gap": null,
      "grid_row": null,
      "grid_template_areas": null,
      "grid_template_columns": null,
      "grid_template_rows": null,
      "height": null,
      "justify_content": null,
      "justify_items": null,
      "left": null,
      "margin": null,
      "max_height": null,
      "max_width": null,
      "min_height": null,
      "min_width": null,
      "object_fit": null,
      "object_position": null,
      "order": null,
      "overflow": null,
      "overflow_x": null,
      "overflow_y": null,
      "padding": null,
      "right": null,
      "top": null,
      "visibility": null,
      "width": null
     }
    },
    "aa027df2dec24e1792825f111ef95805": {
     "model_module": "@jupyter-widgets/controls",
     "model_module_version": "1.5.0",
     "model_name": "HBoxModel",
     "state": {
      "_dom_classes": [],
      "_model_module": "@jupyter-widgets/controls",
      "_model_module_version": "1.5.0",
      "_model_name": "HBoxModel",
      "_view_count": null,
      "_view_module": "@jupyter-widgets/controls",
      "_view_module_version": "1.5.0",
      "_view_name": "HBoxView",
      "box_style": "",
      "children": [
       "IPY_MODEL_6a74007a00504d19992b51c71a81eaa1",
       "IPY_MODEL_c43399c2c69b4f389ee3da4be54da4d9",
       "IPY_MODEL_5002510e5a384d099ace0ab0243b93a4"
      ],
      "layout": "IPY_MODEL_a1d5058472754e4099c024f9671236a3"
     }
    },
    "bec41a931bba4d7ebc31c5ce1089d47a": {
     "model_module": "@jupyter-widgets/controls",
     "model_module_version": "1.5.0",
     "model_name": "FloatProgressModel",
     "state": {
      "_dom_classes": [],
      "_model_module": "@jupyter-widgets/controls",
      "_model_module_version": "1.5.0",
      "_model_name": "FloatProgressModel",
      "_view_count": null,
      "_view_module": "@jupyter-widgets/controls",
      "_view_module_version": "1.5.0",
      "_view_name": "ProgressView",
      "bar_style": "success",
      "description": "",
      "description_tooltip": null,
      "layout": "IPY_MODEL_d3ac6bea6da1423582a7dc9968b83e61",
      "max": 144076467,
      "min": 0,
      "orientation": "horizontal",
      "style": "IPY_MODEL_1cba8110810e4d619e5828c8fc2bbb8e",
      "value": 144076467
     }
    },
    "c0f8bcfa357048db8ed923f8ccbf9a21": {
     "model_module": "@jupyter-widgets/controls",
     "model_module_version": "1.5.0",
     "model_name": "DescriptionStyleModel",
     "state": {
      "_model_module": "@jupyter-widgets/controls",
      "_model_module_version": "1.5.0",
      "_model_name": "DescriptionStyleModel",
      "_view_count": null,
      "_view_module": "@jupyter-widgets/base",
      "_view_module_version": "1.2.0",
      "_view_name": "StyleView",
      "description_width": ""
     }
    },
    "c43399c2c69b4f389ee3da4be54da4d9": {
     "model_module": "@jupyter-widgets/controls",
     "model_module_version": "1.5.0",
     "model_name": "FloatProgressModel",
     "state": {
      "_dom_classes": [],
      "_model_module": "@jupyter-widgets/controls",
      "_model_module_version": "1.5.0",
      "_model_name": "FloatProgressModel",
      "_view_count": null,
      "_view_module": "@jupyter-widgets/controls",
      "_view_module_version": "1.5.0",
      "_view_name": "ProgressView",
      "bar_style": "success",
      "description": "",
      "description_tooltip": null,
      "layout": "IPY_MODEL_2337a836f29f49ea91987e4dbd67a0ff",
      "max": 773236,
      "min": 0,
      "orientation": "horizontal",
      "style": "IPY_MODEL_1849c69ad0dc49e5a27194c3e0fdb1b8",
      "value": 773236
     }
    },
    "c720ecf0b60a44e19d7642da97226db5": {
     "model_module": "@jupyter-widgets/base",
     "model_module_version": "1.2.0",
     "model_name": "LayoutModel",
     "state": {
      "_model_module": "@jupyter-widgets/base",
      "_model_module_version": "1.2.0",
      "_model_name": "LayoutModel",
      "_view_count": null,
      "_view_module": "@jupyter-widgets/base",
      "_view_module_version": "1.2.0",
      "_view_name": "LayoutView",
      "align_content": null,
      "align_items": null,
      "align_self": null,
      "border": null,
      "bottom": null,
      "display": null,
      "flex": null,
      "flex_flow": null,
      "grid_area": null,
      "grid_auto_columns": null,
      "grid_auto_flow": null,
      "grid_auto_rows": null,
      "grid_column": null,
      "grid_gap": null,
      "grid_row": null,
      "grid_template_areas": null,
      "grid_template_columns": null,
      "grid_template_rows": null,
      "height": null,
      "justify_content": null,
      "justify_items": null,
      "left": null,
      "margin": null,
      "max_height": null,
      "max_width": null,
      "min_height": null,
      "min_width": null,
      "object_fit": null,
      "object_position": null,
      "order": null,
      "overflow": null,
      "overflow_x": null,
      "overflow_y": null,
      "padding": null,
      "right": null,
      "top": null,
      "visibility": null,
      "width": null
     }
    },
    "d3ac6bea6da1423582a7dc9968b83e61": {
     "model_module": "@jupyter-widgets/base",
     "model_module_version": "1.2.0",
     "model_name": "LayoutModel",
     "state": {
      "_model_module": "@jupyter-widgets/base",
      "_model_module_version": "1.2.0",
      "_model_name": "LayoutModel",
      "_view_count": null,
      "_view_module": "@jupyter-widgets/base",
      "_view_module_version": "1.2.0",
      "_view_name": "LayoutView",
      "align_content": null,
      "align_items": null,
      "align_self": null,
      "border": null,
      "bottom": null,
      "display": null,
      "flex": null,
      "flex_flow": null,
      "grid_area": null,
      "grid_auto_columns": null,
      "grid_auto_flow": null,
      "grid_auto_rows": null,
      "grid_column": null,
      "grid_gap": null,
      "grid_row": null,
      "grid_template_areas": null,
      "grid_template_columns": null,
      "grid_template_rows": null,
      "height": null,
      "justify_content": null,
      "justify_items": null,
      "left": null,
      "margin": null,
      "max_height": null,
      "max_width": null,
      "min_height": null,
      "min_width": null,
      "object_fit": null,
      "object_position": null,
      "order": null,
      "overflow": null,
      "overflow_x": null,
      "overflow_y": null,
      "padding": null,
      "right": null,
      "top": null,
      "visibility": null,
      "width": null
     }
    },
    "df5cf589b8e1417c983fac215ba3140a": {
     "model_module": "@jupyter-widgets/base",
     "model_module_version": "1.2.0",
     "model_name": "LayoutModel",
     "state": {
      "_model_module": "@jupyter-widgets/base",
      "_model_module_version": "1.2.0",
      "_model_name": "LayoutModel",
      "_view_count": null,
      "_view_module": "@jupyter-widgets/base",
      "_view_module_version": "1.2.0",
      "_view_name": "LayoutView",
      "align_content": null,
      "align_items": null,
      "align_self": null,
      "border": null,
      "bottom": null,
      "display": null,
      "flex": null,
      "flex_flow": null,
      "grid_area": null,
      "grid_auto_columns": null,
      "grid_auto_flow": null,
      "grid_auto_rows": null,
      "grid_column": null,
      "grid_gap": null,
      "grid_row": null,
      "grid_template_areas": null,
      "grid_template_columns": null,
      "grid_template_rows": null,
      "height": null,
      "justify_content": null,
      "justify_items": null,
      "left": null,
      "margin": null,
      "max_height": null,
      "max_width": null,
      "min_height": null,
      "min_width": null,
      "object_fit": null,
      "object_position": null,
      "order": null,
      "overflow": null,
      "overflow_x": null,
      "overflow_y": null,
      "padding": null,
      "right": null,
      "top": null,
      "visibility": null,
      "width": null
     }
    },
    "fb8ae704039945b3906a22dd61068445": {
     "model_module": "@jupyter-widgets/controls",
     "model_module_version": "1.5.0",
     "model_name": "HBoxModel",
     "state": {
      "_dom_classes": [],
      "_model_module": "@jupyter-widgets/controls",
      "_model_module_version": "1.5.0",
      "_model_name": "HBoxModel",
      "_view_count": null,
      "_view_module": "@jupyter-widgets/controls",
      "_view_module_version": "1.5.0",
      "_view_name": "HBoxView",
      "box_style": "",
      "children": [
       "IPY_MODEL_4420fb69a0be4aada0e2a2073304f470",
       "IPY_MODEL_bec41a931bba4d7ebc31c5ce1089d47a",
       "IPY_MODEL_055d380628a048fe87905ea90e498f6e"
      ],
      "layout": "IPY_MODEL_7c913117c35a415a999b5b8fe27193fb"
     }
    },
    "fe0cbb8ecaf64742a9bfc5faf3b6c7d0": {
     "model_module": "@jupyter-widgets/controls",
     "model_module_version": "1.5.0",
     "model_name": "DescriptionStyleModel",
     "state": {
      "_model_module": "@jupyter-widgets/controls",
      "_model_module_version": "1.5.0",
      "_model_name": "DescriptionStyleModel",
      "_view_count": null,
      "_view_module": "@jupyter-widgets/base",
      "_view_module_version": "1.2.0",
      "_view_name": "StyleView",
      "description_width": ""
     }
    }
   }
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
